/*
 * CirculationView.java
 *
 * Created on 22.6.2011, 13:44:02
 */
package net.parostroj.timetable.gui.components;

import java.awt.Color;
import java.awt.Graphics;
import net.parostroj.timetable.model.TrainDiagram;
import net.parostroj.timetable.model.TrainsCycle;

/**
 * View with circulations of certain type.
 *
 * @author jub
 */
public class CirculationView extends javax.swing.JPanel {
    
    private TrainDiagram diagram;
    private String message;

    /** Creates new form CirculationView */
    public CirculationView() {
        initComponents();
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (diagram != null) {
            g.setColor(Color.black);
            g.drawString(diagram.toString(), 10, 15);
            
            if (message != null) {
                g.drawString(message, 10, 30);
            }
        }
    }

    public void setDiagram(TrainDiagram diagram) {
        this.diagram = diagram;
        this.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBackground(new java.awt.Color(255, 255, 255));
        setLayout(null);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

    public void circulationRemoved(TrainsCycle circulation) {
        message = "Removed: " + circulation.getName();
        this.repaint();
    }

    public void circulationAdded(TrainsCycle circulation) {
        message = "Added: " + circulation.getName();
        this.repaint();
    }

    public void circulationUpdated(TrainsCycle circulation) {
        message = "Updated: " + circulation.getName();
        this.repaint();
    }
}
